package com.allwees.bs.module.pms.req.query;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.allwees.bs.core.modelbase.req.QueryReq;
import com.allwees.bs.module.pms.entity.Category;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.apache.commons.lang3.StringUtils;

/**
 *
 *
 * @author yangylsky
 * @since 2019-08-29
 *
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ToString
public class CategoryQueryReq extends QueryReq<Category> {
	private static final long serialVersionUID = 6027228820309338910L;
	private String parentUuid;

	private String parentNo;

	@Override
	public void buildQuery(QueryWrapper<Category> queryWrapper) {
		queryWrapper
				.eq(StringUtils.isNotBlank(parentUuid), "parent_uuid", parentUuid)
				.eq(StringUtils.isNotBlank(parentNo), "parent_no", parentNo)
				.and(StringUtils.isNotBlank(q), wrapper -> wrapper.eq("name", "%" + q + "%").or().eq("name_zh", "%" + q + "%"));
	}
}
